Path: blob/master/Part 3 - Classification/Naive Bayes/[R] Naive Bayes.ipynb
1009 views
Kernel: R
Naive Bayes
Data preprocessing
In [1]:
In [2]:
Out[2]:
In [3]:
In [4]:
In [5]:
Out[5]:
In [6]:
Out[6]:
In [7]:
In [8]:
Out[8]:
In [9]:
Out[9]:
Fitting Naive Bayes classifier to the Training set
In [10]:
Predicting the Test set results
In [11]:
In [12]:
Out[12]:
In [13]:
Out[13]:
Making the Confusion Matrix
In [14]:
Out[14]:
y_pred
0 1
0 48 3
1 6 23
classifier made 48 + 23 = 71 correct prediction and 6 + 3 = 9 incoreect predictions.
Visualising the Training set results
In [15]:
Out[15]:
Visualising the Test set results
In [16]:
Out[16]:
Naive Bayes is another non-linear classifier. It works on the principle of Bayes theorem.
Here we can see that we got a pretty good classifier with very fewer incorrect predictions. Though no classifier is 100% correct.
Every classifier is wrong , but some are useful.